/*
 * Copyright 2010 WANdisco, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License. 
 */
package com.googlecode.svnj;

public class NOOPDeltaEditor implements IDeltaEditor {
    
    StringBuilder buf = new StringBuilder();
    public void abortEdit() {
        p("abortEdit()");
    }
    
    public void absentDirectory(String path) {
        p("absentDir(" + path + ")");
    }
    
    public void absentFile(String path) {
        p("absentFile(" + path + ")");
    }
    
    public void addDirectory(String path, String copyFromPath,
            long copyFromRevision) {
        p("addDir(" + path + "," + copyFromPath + ", " + copyFromRevision + ")");
    }
    
    public void addFile(String path, String copyFromPath, long copyFromRevision) {
        p("addFile(" + path + "," + copyFromPath + ", " + copyFromRevision + ")");
    }
    
    public void beginTextDelta(String baseChecksum) {
        p("beginTextDelta(" + baseChecksum + ")");
    }
    
    public void appendTextDelta(String deltaText) {
        p("appendTextDelta(" + deltaText + ")");
        buf.append(deltaText);
    }
    
    public void endTextDelta() {
        p("endTextDelta()###");
        System.out.print(buf);
        p("###");
        buf.setLength(0);
    }
    
    public void changeDirProp(String name, String value) {
        p("changeDirProp(" + name + "," + value + ")");
    }
    
    public void changeFileProp(String name, String value) {
        p("changeFileProp(" + name + "," + value + ")");
    }
    
    public void closeDirectory() {
        p("closeDirectory()");
    }
    
    public void closeEdit() {
        p("closeEdit()");
    }
    
    public void closeFile(String txtChecksum) {
        p("closeFile(" + txtChecksum + ")");
    }
    
    public void deleteEntry(String path, long revision) {
        p("deleteEntry(" + path + "," + revision + ")");
    }

    public void openDirectory(String path, long baseRevision) {
        p("openDirectory(" + path + "," + baseRevision + ")");
    }
    
    public void openFile(String path, long baseRevision) {
        p("openFile(" + path + "," + baseRevision + ")");
    }

    public void openRoot(long revision) {
        p("openRoot(" + revision + ")");
        // Exception to test error handling/propagation
        //if (true) throw new RuntimeException("deliberate exception!");
    }
    
    public void setTargetRevision(long revision) {
        p("setTargetRevision(" + revision + ")");
    }

    static void p(String s) {
        System.out.println("[NOOP] " + s);
    }
}
